<template>
  <div style="padding:30px">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="客户名称" prop="title">
        <el-input v-model="queryParams.userName" placeholder="客户名称" clearable
          @keyup.enter.native="getList" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 视频列表 -->
    <el-table border :data="feedbackList">
      <el-table-column type="index" label="序号" align="center"></el-table-column>
      <el-table-column prop="type" label="类型" align="center" :show-overflow-tooltip="true" width="120">
        <template slot-scope="scope"> {{getTypeName(scope.row)}} </template>
      </el-table-column>
      <el-table-column prop="userName" label="客户名称" :show-overflow-tooltip="true" width="280">
      </el-table-column>
      <el-table-column prop="mobile" label="手机号" :show-overflow-tooltip="true" width="120">
      </el-table-column>
      <el-table-column prop="context" label="反馈内容" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column prop="createTime" label="反馈时间" :show-overflow-tooltip="true" width="160">
      </el-table-column>
      <el-table-column label="操作" align="center" width="150">
        <template slot-scope="scope">
          <!--
          <el-button size="mini" @click="getVideoItemInfo(scope.row)">查看</el-button>
          -->
          <el-button size="mini" @click="deleteItem(scope.row)" v-hasPermi="['feedback:feedback:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
import { getToken } from "@/utils/auth"
import { listFeedback, deleteFeedback, listFeedbackType } from '@/api/mallAdmin/feedback.js'

export default {
  name: 'Video',
  data () {
    return {
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 遮罩层
      loading: true,
      feedbackList: [],

      dialogVisible: false,
      videoItemInfo: {},
      feedbackTypeList: [],
    }
  },
  created () {
    this.getFeedbackTypeList()
    this.getList()
  },
  methods: {
    // 获取列表
    getList () {
      listFeedback(this.queryParams).then(res => {
        if (res.code === 200) {
          this.feedbackList = res.rows
          this.total = res.total
        }
      })
    },
    getFeedbackTypeList(){
      listFeedbackType().then(res => {
        if (res.code === 200) {
          this.feedbackTypeList = res.data
        }
      })
    },
    // 重置
    resetQuery () {
      this.queryParams = {}
      this.queryParams.pageNum = 1
      this.queryParams.pageSize = 10
      this.getList()
    },
    deleteItem(item){
      const _this = this
      this.$modal.confirm('确认此条记录吗？').then(function () {
        deleteFeedback(item.id).then(function(){
          _this.getList()
        })
      })
    },
    getTypeName (row) {
      for(let i = 0; i < this.feedbackTypeList.length; i++){
        let item = this.feedbackTypeList[i]

        if (item.code === row.type) {
          return item.name
        }
      }
      return ''
    },
  }
};
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  top: 0;
  padding: 0;
}
</style>
